package com.vae.virtualanimationexperiment.controller;

import com.vae.virtualanimationexperiment.domain.ResponseResult;
import com.vae.virtualanimationexperiment.domain.form.CodeForm;
import com.vae.virtualanimationexperiment.domain.form.LoginForm;
import com.vae.virtualanimationexperiment.domain.form.RegisterForm;
import com.vae.virtualanimationexperiment.domain.form.RetrievePwdForm;
import com.vae.virtualanimationexperiment.service.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 用户表(User)表控制层
 *
 * @author makejava
 * @since 2023-03-05 20:39:22
 */
@CrossOrigin
@RestController
@RequestMapping("user")
public class UserController {

    @Resource
    private UserService userService;

    /**
     * 登陆
     *
     * @param loginForm
     * @return
     */
    @PostMapping("/login")
    public ResponseResult login(@RequestBody LoginForm loginForm) {
        return userService.login(loginForm);
    }

    /**
     * 退出
     *
     * @return
     */
    @PostMapping("/logout")
    public ResponseResult logout() {
        return userService.logout();
    }

    /**
     * 获取注册邮箱验证码
     * @return
     */
    @GetMapping("/email/verificationcode/{userName}")
    public ResponseResult getVerificationCode(@PathVariable String userName) {
        return userService.getVerificationCode(userName);
    }

    /**
     * 注册
     *
     * @param registerForm
     * @return
     */
    @PostMapping("/regist")
    public ResponseResult regist(@RequestBody RegisterForm registerForm) {
        return userService.regist(registerForm);
    }
}

